package controllers

import (
	"net/http"

	"github.com/astaxie/beego/logs"
	"github.com/astaxie/beego/session"
)

func PageNotFound(rw http.ResponseWriter, r *http.Request) {
	rw.WriteHeader(http.StatusNotFound)
	rw.Write([]byte("404 Not Fond"))
}

func ServerError(rw http.ResponseWriter, r *http.Request) {
	rw.WriteHeader(http.StatusInternalServerError)
	rw.Write([]byte("500 Server Error"))
}

var globalSessions *session.Manager

func init() {
	sessionConfig := &session.ManagerConfig{
		CookieName:      "gosessionid",
		EnableSetCookie: true,
		Gclifetime:      3600,
		Maxlifetime:     3600,
		Secure:          false,
		CookieLifeTime:  3600,
	}
	globalSessions, err := session.NewManager("memory", sessionConfig)
	if err != nil {
		logs.Error("Session初始化失败：" + err.Error())
	}
	go globalSessions.GC()
}
